Next | Prev | Up | Top | Contents | Index

The GLXFBConfig Construct

A GLXFBConfig describes the format, type, and size of the color buffer and ancillary buffers for a GLX drawable. When the GLX drawable is a window, then the GLXFBConfig that describes it has an associated X visual; for a GLXPixmap or GLXPbuffer there may or may not be an X visual associated with the GLXFBConfig.


Choosing a GLXFBConfig Construct

Use glXChooseFBConfigSGIX() to get GLXFBConfig constructs that match a list of attributes or to get the list of GLXFBConfig constructs (GLXFBConfigs) that are available on the specified screen.

GLXFBConfig *glXChooseFBConfigSGIX(Display *dpy, int screen,
                     const int *attrib_list, int *nitems)
If attrib_list is NULL, glXChooseFBConfigSGIX() returns an array of GLXFBConfigs that are available on the specified screen; otherwise this call returns an array of GLXFBConfigs that match the specified attributes. Table 9-2 shows only attributes specified by this extension; additional attributes are listed on the glXChooseVisual() reference page.

Attributes Introduced by GLXFBConfig
AttributeTypeDescription
GLX_DRAWABLE_TYPE_SGIXbitmaskMask indicating which GLX drawables are supported. Valid bits are GLX_WINDOW_BIT_SGIX and GLX_PIXMAP_BIT_SGIX.
GLX_RENDER_TYPE_SGIXbitmaskMask indicating which OpenGL rendering modes are supported. Valid bits are GLX_RGBA_BIT_SGIX and GLX_COLOR_INDEX_BIT_SGIX.
GLX_X_RENDERABLE_SGIXBooleanTrue if X can render to drawable.
GLX_FBCONFIG_ID_SGIXXIDXID of GLXFBConfig.

The attributes are matched in an attribute-specific manner. Some attributes, such as GLX_LEVEL, must match the specified value exactly; others, such as GLX_RED_SIZE, must meet or exceed the specified minimum values. The sorting criteria are defined as follows:

smaller

GLXFBConfigs with an attribute value that meets or exceeds the specified value are matched. Precedence is given to smaller values (when a value is not explicitly requested, the default is implied).

larger

When the value is requested explicitly, only GLXFBConfigs with a corresponding attribute value that meets or exceeds the specified value are matched. Precedence is given to larger values. When the value is not requested, explicitly behaves exactly like the "smaller" criterion.

exact

Only GLXFBConfigs whose corresponding attribute value exactly matches the requested value are considered.

mask

For a config to be considered, all the bits that are set in the requested value must be set in the corresponding attribute. (Additional bits might be set in the attribute.)
Note also that "don't care" means that the default behavior is to have no preference when searching for a matching GLXFBConfig.

Table 9-3 illustrates how each attribute is matched.

GLXFBConfig Attribute Defaults and Sorting Criteria
AttributeDefaultSorting Criteria
GLX_BUFFER_SIZE 0smaller
GLX_LEVEL 0 smaller
GLX_DOUBLEBUFFER don't caresmaller
GLX_STEREO Falseexact
GLX_AUX_BUFFERS 0smaller
GLX_RED_SIZE 0 larger
GLX_GREEN_SIZE 0 larger
GLX_BLUE_SIZE 0 larger
GLX_ALPHA_SIZE 0 larger
GLX_DEPTH_SIZE 0 larger
GLX_STENCIL_SIZE 0 larger
GLX_ACCUM_RED_SIZE 0 larger
GLX_ACCUM_GREEN_SIZE 0larger
GLX_ACCUM_BLUE_SIZE 0larger
GLX_ACCUM_ALPHA_SIZE 0larger
GLX_SAMPLE_BUFFERS_SGIS 0 if GLX_SAMPLES_
SGIS = 0, 1 otherwise
smaller
GLX_SAMPLES_SGIS 0smaller
GLX_X_VISUAL_TYPE_EXTdon't careexact
GLX_TRANSPARENT_TYPE_EXT GLX_NONE_EXTexact
GLX_TRANSPARENT_INDEX_VALUE_EXT don't careexact
GLX_TRANSPARENT_RED_VALUE_EXT don't careexact
GLX_TRANSPARENT_GREEN_VALUE_EXTdon't careexact
GLX_TRANSPARENT_BLUE_VALUE_EXT don't careexact
GLX_TRANSPARENT_ALPHA_VALUE_EXT don't careexact
GLX_VISUAL_CAVEAT_EXTGLX_NONE_EXTexact, if specified, otherwise minimum.
GLX_DRAWABLE_TYPE_SGIXGLX_WINDOW_BIT_
SGIX
mask
GLX_RENDER_TYPE_SGIXGLX_RGBA_BIT_SGIXmask
GLX_X_RENDERABLE_SGIX don't care exact
GLX_FBCONFIG_ID_SGIXdon't careexact

There are several uses for the glXChooseFBConfigSGIX() function:

Once the GLXFBConfig is obtained, you can use it to create a GLX pixmap, window, or pbuffer (see "The Pixel Buffer Extension"). In the case of a window, you must first get the associated X visual by calling glXGetVisualFromFBConfigSGIX().

Below is a description of what happens when you call glXChooseFBConfigSGIX():

If a GLXFBConfig supports windows it has an associated X visual. Use the GLX_X_VISUAL_TYPE_EXT attribute to request a particular type of X visual.

Note that RGBA rendering may be supported for any of the six visual types, but color index rendering can be supported only for PseudoColor, StaticColor, GrayScale, and StaticGray visuals (that is, single-channel visuals). The GLX_X_VISUAL_TYPE_EXT attribute is ignored if GLX_DRAWABLE_TYPE_SGIX is specified in attrib_list and the mask that follows does not have GLX_WINDOW_BIT_SGIX set.

GLX_X_RENDERABLE_SGIX is a Boolean indicating whether X can be used to render into a drawable created with the GLXFBConfig. This attribute is always True if the GLXFBConfig supports windows and/or GLX pixmaps.


Retrieving GLXFBConfig Attribute Values

To get the value of a GLX attribute for a GLXFBConfig, call

int glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfig config, 
                            int attribute, int *value)
If glXGetFBConfigAttribSGIX() succeeds, it returns Success, and the value for the specified attribute is returned in value; otherwise it returns an error.

Note: A GLXFBConfig has an associated X visual if and only if the GLX_DRAWABLE_TYPE_SGIX value has the GLX_WINDOW_BIT_SGIX bit set. To retrieve the associated visual, call:

XVisualInfo *glXGetVisualFromFBConfigSGIX(Display *dpy,
                                         GLXFBConfig config)
If config is a valid GLXFBConfig and it has an associated X visual, then information describing that visual is returned; otherwise NULL is returned. Use XFree() to free the returned data.

It is also possible to get a GLXFBConfig, given visual information:

GLXFBConfig glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
If the visual is valid and supports OpenGL rendering (that is, if the GLX visual attribute GLX_USE_GL is True) then the associated GLXFBConfig is returned; otherwise NULL is returned.

To create a GLX rendering context or a GLX pixmap using a GLXFBConfig, call glXCreateContextWithConfigSGIX() or glXCreateGLXPixmapWithConfigSGIX(). The functions are similar to glXCreateContext() and glXCreateGLXPixmap(). See the reference page for detailed information.


Next | Prev | Up | Top | Contents | Index